package com.huaju.enity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * RoleType entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "role_type", catalog = "licai")
@JsonIgnoreProperties(value={"admins"})
public class RoleType implements java.io.Serializable {

	// Fields

	private Integer typeId;
	private String name;
	private Set<UserRole> userRoles = new HashSet<UserRole>(0);
	private Set<Admin> admins = new HashSet<Admin>(0);

	// Constructors

	/** default constructor */
	public RoleType() {
	}

	/** full constructor */
	public RoleType(String name, Set<UserRole> userRoles, Set<Admin> admins) {
		this.name = name;
		this.userRoles = userRoles;
		this.admins = admins;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "type_id", unique = true, nullable = false)
	public Integer getTypeId() {
		return this.typeId;
	}

	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}

	@Column(name = "name", length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "roleType")
	public Set<UserRole> getUserRoles() {
		return this.userRoles;
	}

	public void setUserRoles(Set<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "roleType")
	public Set<Admin> getAdmins() {
		return this.admins;
	}

	public void setAdmins(Set<Admin> admins) {
		this.admins = admins;
	}

}